package com.zjbti.commonview;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

public class RadioButtonActivity extends AppCompatActivity {
    private TextView textView4;
    private TextView textViewRadio;
    private RadioGroup radioGroup2;
    private RadioButton boy;
    private RadioButton girl;




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_radio_button);
        textView4 = findViewById(R.id.textView4);
        textViewRadio = findViewById(R.id.textViewRadio);
        radioGroup2 = findViewById(R.id.radioGroup2);
        boy = findViewById(R.id.boy);
        girl = findViewById(R.id.girl);
        radioGroup2.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId==R.id.boy){
                    textView4.setText("您的性别是：男");
                } else {
                    textView4.setText("您的性别是：女");
                }
            }
        });

    }
}